package com.etc.service.impl;

import com.etc.dao.FxMusicMapper;
import com.etc.entity.FxMusic;
import com.etc.entity.FxPlaylist;
import com.etc.service.FxMusicService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FxMusicServiceImpl implements FxMusicService {

    @Autowired
    private FxMusicMapper mapper;

    private Logger logger = LogManager.getLogger(getClass());

    @Override
    public boolean deleteByPrimaryKey(Integer id) {
        logger.debug("deleteByPrimaryKey : "+id);
        int i = mapper.deleteByPrimaryKey(id);
        return i>0;
    }

    @Override
    public int insert(FxMusic record) {
        logger.debug("insert : "+record);
        return mapper.insert(record);
    }



    @Override
    public FxMusic selectByPrimaryKey(Integer id) {
        logger.debug("selectByPrimaryKey : "+id);
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean updateByPrimaryKeySelective(FxMusic record) {
        logger.debug("updateByPrimaryKeySelective : "+record);
        int i = mapper.updateByPrimaryKeySelective(record);
        return i>0;
    }

    @Override
    public boolean updateByPrimaryKey(FxMusic record) {
        logger.debug("updateByPrimaryKey : "+record);
        int i = mapper.updateByPrimaryKey(record);
        return i>0;
    }

    @Override
    public Page<FxMusic> selectByPage(String keywords,int page,int limit) {
        logger.debug("selectByPage : "+keywords+" , "+page+" , "+limit);
        PageHelper.startPage(page,limit);
        Page<FxMusic> fxMusics = mapper.selectByPage("%"+keywords+"%");
        return fxMusics;
    }

    @Override
    public Page<FxMusic> selectByUserid(Integer pageNo, Integer pageSize, Integer userid) {
        PageHelper.startPage(pageNo,pageSize);
        Page<FxMusic> fxMusic = mapper.selectByUserid(userid);
        return  fxMusic;
    }


}
